﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvLookEntry";
                settings.KeyFieldName = "xh";
                settings.CallbackRouteValues = new { Controller = "AllowanceCalcManage", Action = "LookEntryPartial" };
                settings.Width = System.Web.UI.WebControls.Unit.Percentage(99);


                settings.Columns.Add("xh", "序号");

                settings.Columns.Add("RKRQStr", "入库日期");
                settings.Columns.Add("se", "税额");
                //"isAdjust", "调整数据"
                settings.Columns.Add(s => {
                    s.FieldName = "isAdjust";
                    s.Caption = "调整数据";
                    s.SetDataItemTemplateContent(c =>
                    {
                        Html.DevExpress().CheckBox(cb => {
                            cb.Name = "cb" + c.ItemIndex;
                            if (DataBinder.Eval(c.DataItem, "isAdjust").ToString() == "Y")
                            {
                                cb.Checked = true;
                            }
                            else
                            {
                                cb.Checked = false;
                            }
                            cb.Enabled = false;
                        }).GetHtml();
                     
                    });
                });
                settings.Columns.Add("AdjustName", "调整人员");
                settings.Columns.Add("AdjustNote", "调整原因");
                
                settings.Columns["se"].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
                settings.TotalSummary.Add(DevExpress.Data.SummaryItemType.Sum, "se").DisplayFormat = "合计:￥{0}";
                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;
                settings.Settings.ShowFooter = true;

                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                
                settings.CommandColumn.Visible = false;
                settings.CommandColumn.ShowSelectCheckbox = false;

                settings.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
                settings.SettingsPager.FirstPageButton.Visible = true;
                settings.SettingsPager.LastPageButton.Visible = true;
                settings.SettingsPager.PageSize = 10;
                settings.SettingsPager.AlwaysShowPager = true;
                                
                
                settings.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };
                settings.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };            
                
                
            }).Bind(Model).GetHtml()